package com.lcsp.client.zoo;

import java.io.IOException;
import java.util.ResourceBundle;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;

public class ZKClient {
	public static final String zooUrl;
	public static final int zooPort;
	private static final ResourceBundle res;
	static{
		res = ResourceBundle.getBundle("conf");
		zooUrl = res.getString("zookeeper.url");
		zooPort = Integer.parseInt(res.getString("zookeeper.port"));
	}
	
	public static void main(String[] args) throws IOException, KeeperException, InterruptedException {
		// 连接zookeeper服务器
		ZooKeeper zoo = new ZooKeeper(zooUrl + ":" + zooPort + "/rootNode/test6"
				, 100, new Watcher(){
					// 监控zookeeper事件
					public void process(WatchedEvent event) {
						System.out.println("已发生：" + event.getType() + " 事件");
					}
			
		});
		
		while(true){
			Thread.sleep(5000);
		}
	}
}